#include <iostream>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <cstring>
#include <unistd.h>
#include "comm.hpp"
using namespace std;
int main()
{
    key_t key = getkey();

    int shmid = GetShm(key);

    char *s = (char *)shmat(shmid, nullptr, 0);
    cout << "attach shm done" << endl;
    char c = 'a';

    int wfd = open(filename.c_str(), O_WRONLY);
    for (; c <= 'z'; c++)
    {
        s[c - 'a'] = c;
        cout << "wirte: " << c << " done!" << endl;
        sleep(1);

        int code = 1;
        write(wfd, &code, sizeof(code));
    }
    shmdt(s);
    cout << "dttach shm done" << endl;
    return 0;
}